home *** CD-ROM | disk | FTP | other *** search
/ PC Media 2 / PC MEDIA CD02.iso / share / prog / qbser310 / qbserial.doc < prev    next >
Encoding:
Text File  |  1993-06-11  |  43.8 KB  |  897 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                                  QBserial version 3.10
  7.  
  8.             Serial I/O Routines for QB 4.x, BC 7.x, VBDOS, & FOSSIL Drivers
  9.  
  10.           This library will provide you with serial I/O communications
  11.           routines for use in QuickBASIC 4.x (with or without PDQ), the
  12.           Microsoft Basic Compiler 7.x Professional Development System, and
  13.           Visual Basic for DOS 1.x. No longer are you forced to use the poor
  14.           communications support provided by QB.  This program will allow you
  15.           to control 8250 and 16450 type communications ports (UARTS) at
  16.           speeds of up to 115200 baud. Communication ports 1 - 4, and non-
  17.           standard addresses are supported. You will no longer have problems
  18.           with the DTR signal. DTR is left in the same state it was in when
  19.           before you called this driver, or it can be controlled by your
  20.           program. The serial driver includes XON/XOFF and CTS/RTS
  21.           handshaking. Serial input is interrupt driven, using any IRQ you
  22.           specify (1 - 15), with incoming XOFF flow control (if enabled), or
  23.           RTS flow control (if enabled) to prevent overrunning the input
  24.           buffer. This is referred to as "Normal" mode. 
  25.  
  26.           This driver also has a mode where it will operate with FOSSIL
  27.           drivers (INT 14h interface). Using FOSSIL mode allows you to use
  28.           virtually any type of communications hardware, since the type of
  29.           hardware accessed is dependant on the FOSSIL driver. This mode
  30.           requires that you have a FOSSIL driver loaded in advance. This is
  31.           referred to as "FOSSIL" mode.
  32.  
  33.           The driver was written with Microsoft's C, and compiled with
  34.           version 6.0a of that compiler. This driver is useable with
  35.           QuickBASIC version 4.x, and Basic Compiler 6.x & 7.x PDS  (With or
  36.           without PDQ), and Visual Basic for DOS version 1.x. Basic Compiler
  37.           1.x, QuickBASIC 2.x, and 3.x are not supported by this driver. The
  38.           reason is that versions of QuickBASIC prior to 4.0 do not support
  39.           the extensive multi-language interface that QB4.x has (via the
  40.           DECLARE statement and Microsoft language extensions). Throughout
  41.           this manual QB will be used to refer to both QuickBASIC, the Basic
  42.           Compilers (6.x & 7.x PDS), and Visual Basic for DOS.
  43.  
  44.           Before the driver can be used, the following INCLUDE statement must
  45.           be added to the beginning of your QB program:
  46.  
  47.           '    $INCLUDE: 'qbserial.dec'
  48.  
  49.           The declarations included by this statement specify all the entry
  50.           points into the serial driver. DO NOT change them or the driver
  51.           will not function.
  52.  
  53.           Refer to the included sample programs SIMPLE.BAS, PCBDOOR.BAS, and
  54.           OFFHOOK.BAS. they use most of the calls described below.
  55.  
  56.  
  57.  
  58.         QBSERIAL User Manual - V 3.10                              Page 1
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.           Qbserial has two (2) modes of operation: Normal and FOSSIL. The
  66.           mode you operate in is specified in the OpenComm statement (The
  67.           FOS% parameter). In the following sections, where applicable, each
  68.           parameter will be explained as to how it operates in both Normal
  69.           and FOSSIL mode.
  70.  
  71.                                   Port Initialization
  72.  
  73.           OpenComm Port%, IRQ/Stat%, Wordlen%, Parity%, Baudrate&, HS%, FOS%
  74.  
  75.           Parameter:     Port%
  76.  
  77.           Normal:   If the specified port is 1 to 4, the driver opens that
  78.                     port. If you specify the port as ZERO (0) the driver
  79.                     enters "LOCAL" mode. This allows you to call the driver
  80.                     with data, but the driver won't send anything. This is
  81.                     useful when working with "doors". if you specify the port
  82.                     as any other value, QBserial will use that as the base
  83.                     address for the port. This allows you to work with non-
  84.                     standard I/O addresses. Note however that if you open a
  85.                     non-standard port, you must specify an IRQ value from 1
  86.                     to 15 - There is no default IRQ when used in this manner.
  87.  
  88.           FOSSIL:   Unlike normal mode, "port" does not necessarily relate to
  89.                     a specific communications port or address. Using a "1"
  90.                     for a port value does NOT necessarily mean COM1. Also
  91.                     unlike QBserial's normal mode, a value other than 1 - 4
  92.                     does NOT refer to a base address of a UART.
  93.  
  94.                     When using FOSSIL mode, "port" refers to a logical
  95.                     device. Port 0 is the first port of a FOSSIL device
  96.                     driver, Port 1 the second, and so on. When used with
  97.                     drivers such as X00.SYS (assuming you didn't remap the
  98.                     ports), port 0 refers to COM1, and port 1 refers to COM2.
  99.                     This will vary depending on the FOSSIL driver used and
  100.                     the device(s) referenced. In most cases it is determined
  101.                     when the FOSSIL driver is installed through some sort of
  102.                     configuration file (or command line options) that relates
  103.                     the physical devices to logical port numbers. However, in
  104.                     order to make the FOSSIL implementation as compatible as
  105.                     possible with "normal" mode, the port number passed will
  106.                     have a value of ONE (1) subtracted from it before
  107.                     referring to the actual FOSSIL port. Therefore to access
  108.                     the first port (port 0), you pass a 1 as you did with in
  109.                     normal mode. Internally, one (1) is subtracted so that
  110.                     port 0 is referenced. This makes the implementation or
  111.                     normal and FOSSIL modes totally transparent.
  112.  
  113.                     Specifying a value of ZERO (0) for the port puts the
  114.                     driver in "local" mode. This is identical to normal mode.
  115.  
  116.         QBSERIAL User Manual - V 3.10                              Page 2
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.           Parameter:     IRQ/Stat%
  124.  
  125.           Normal:   Specifies which interrupt to use with this port. If the
  126.                     value of IRQ% is ZERO (0), then the default IRQ values
  127.                     are used (COM1 & COM3 use IRQ4, COM2 & COM4 use IRQ3).
  128.                     This is what most applications will use. Specify an IRQ
  129.                     value of 1 through 15 when you want to use an IRQ value
  130.                     other than the default. Such as when you want to use
  131.                     IRQ15 with COM3. NOTE: Be careful when choosing an IRQ
  132.                     value other than the default. Most machines use some of
  133.                     the other IRQ inputs for other machine functions such as
  134.                     the Hard drive and system clock. QBserial DOES NOT chain
  135.                     the interrupt, it takes it over entirely. If you choose
  136.                     an IRQ that is used for something already, your machine
  137.                     will most certainly operate improperly.
  138.  
  139.           FOSSIL:   No IRQ value is necessary in FOSSIL mode since all
  140.                     communications tasks are handled outside of QBserial. The
  141.                     IRQ used with a particular "port" will be determined at
  142.                     the time the FOSSIL driver is installed, probably through
  143.                     the same configuration method mentioned above.
  144.  
  145.                     When using FOSSIL mode, this field is now Status. This is
  146.                     a value RETURNED to the programmer when OpenComm has
  147.                     completed. It indicates whether or not the FOSSIL driver
  148.                     initialized properly and is ready to perform
  149.                     communications tasks. A value of 1954h (HEX) or 6484
  150.                     (DECIMAL) indicates a successful initialization. ANY
  151.                     OTHER value indicates a initialization failure. You
  152.                     should terminate your program and inform the user of your
  153.                     program of the problem. Failures could result from the
  154.                     FOSSIL driver not being installed, or not installed
  155.                     properly. If you pass an invalid baud rate (see below),
  156.                     Status will be returned as a ZERO. Otherwise Status will
  157.                     be the actual value returned from the FOSSIL driver in
  158.                     response to initialization. These values other than
  159.                     1954h/6484 may offer a clue as to why the driver did not
  160.                     initialize. These "possible" values would be documented
  161.                     in the documentation for the FOSSIL driver.
  162.  
  163.           Parameter:     Wordlen%
  164.  
  165.                     An integer specifying the word length of the serial data.
  166.                     It has a value of 7 or 8. Identical in both modes.
  167.  
  168.           Parameter:     Parity%
  169.  
  170.                     An integer, 0 = NONE, 1 = ODD, 2 = EVEN. Identical in
  171.                     both modes.
  172.  
  173.  
  174.         QBSERIAL User Manual - V 3.10                              Page 3
  175.  
  176.  
  177.  
  178.  
  179.           Parameter:     BaudRate&
  180.  
  181.           Normal:   This is a LONG INTEGER representing the desired baud
  182.                     rate. Valid numbers are 0, 300, 1200, 2400, 4800, 9600,
  183.                     19200, 38400, 57600, and 115200. The value you send is
  184.                     NOT checked and I assume you could generate crazy baud
  185.                     rates if desired. 115200 is the absolute maximum rate
  186.                     that can be generated. If you specify a baud rate of ZERO
  187.                     then the serial port is used AS-IS. The rate, word
  188.                     length, & parity are NOT changed. This is useful for door
  189.                     operation since the port is already initialized at the
  190.                     proper settings when you get control.
  191.  
  192.           FOSSIL:   Identical to normal mode with the exception being that
  193.                     the range of selectable baudrates is limited. This is
  194.                     limited by the current FOSSIL specification. The valid
  195.                     baud rates are: 0, 300, 1200, 2400, 4800, 9600, 19200,
  196.                     and 38400. If you pass a value other than one of these
  197.                     valid rates, the driver will not initialize and return a
  198.                     ZERO for status. In FOSSIL mode, if you specify a baud
  199.                     rate of ZERO (0), the Baudrate initialization call is not
  200.                     performed by OpenComm. This *SHOULD* have the same effect
  201.                     that normal mode does by not changing the baudrate, word
  202.                     length, & parity. However, since this is an undefined
  203.                     condition in the FOSSIL specification, there is no way of
  204.                     guaranteeing that the current settings will not be
  205.                     changed during initialization of the driver. If you want
  206.                     a 100% guarantee of the rate setting, you should provide
  207.                     a speed when you do an OpenComm. This is only being done
  208.                     for compatibility with Normal mode.
  209.  
  210.           Parameter:     HS%
  211.  
  212.                     An integer specifying the type of handshake you wish to
  213.                     use between the CPU and Modem (or destination device).
  214.                     Valid numbers are: 0 = NO handshake, 1 = XON/XOFF, 2 =
  215.                     CTS/RTS, 3 = XON/XOFF and CTS/RTS. Identical in both
  216.                     modes.
  217.  
  218.           Parameter:     FOS%
  219.  
  220.                     An integer that specifies which mode the driver will
  221.                     operate in. Zero (0) specifies "Normal" mode, and One (1)
  222.                     specifies "FOSSIL" mode.
  223.  
  224.  
  225.                                      Serial Output
  226.  
  227.           To send a string of data out the serial port, you use the
  228.           "Transmit" call as follows:
  229.  
  230.                Temp$ = "Transmit this..."
  231.  
  232.         QBSERIAL User Manual - V 3.10                              Page 4
  233.  
  234.  
  235.  
  236.  
  237.                Transmit Temp$
  238.  
  239.                     or
  240.  
  241.                Transmit "Send this also...."
  242.  
  243.           If you want to transmit single characters, you can use the
  244.           "WriteChar" function. Transmit calls WriteChar to send the actual
  245.           characters to the port. If you wish to use WriteChar, it has the
  246.           following format:
  247.  
  248.                Status% = WriteChar(Char%)
  249.  
  250.           Char% is the integer value of the character you want to send, it is
  251.           not a string. Status% is an integer returned by WriteChar, it is
  252.           NON-ZERO if the character was actually sent to the port, and ZERO
  253.           if the character was not sent. WriteChar will loop indefinitely on
  254.           CTS hold, XOFF hold, or Transmit Buffer Busy. These loops will exit
  255.           if carrier is lost in FULL or PARTIAL modes and return a ZERO
  256.           status% (This occurs in normal mode ONLY. What happens in FOSSIL
  257.           mode is undefined). WriteChar gives you more low level control of
  258.           the sending of characters, but you must send each character
  259.           separately and monitor its status.
  260.  
  261.           The Transmit function monitors the status of its calls to WriteChar
  262.           and triggers QuickBASIC's User Event trap (UEVENT) if a carrier
  263.           loss occurs in FULL mode. The UEVENT trap (FULL mode) is used by
  264.           default. You can disable the use of this event trap in the event
  265.           you already use the UEVENT trap for something else (PARTIAL mode).
  266.           Therefore, by default, carrier loss detection in your program is
  267.           done with the ON UEVENT GOSUB/UEVENT ON statements. The example
  268.           programs show the use of this method. By default UEVENT is also
  269.           used for catching carrier loss on keyboard input. this is described
  270.           below.
  271.  
  272.  
  273.  
  274.                                       Serial Input
  275.  
  276.           Serial input is managed with three functions: DataWaiting,
  277.           ReadChar, & ClearInputBuffer. DataWaiting is used to test the input
  278.           buffer to see if any characters need to be read from it. ReadChar
  279.           is then called to get the characters. ClearInputBuffer flushes the
  280.           input buffer of any existing characters. Both example programs
  281.           contain a subroutine called "KeyboardInput" that demonstrates the
  282.           use of these calls. It also properly handles input from the local
  283.           and remote keyboards, and can be the routine you use in your
  284.           programs if you wish. Basically the procedure for reading the
  285.           remote keyboard (serial input) is as follows:
  286.  
  287.  
  288.  
  289.  
  290.         QBSERIAL User Manual - V 3.10                              Page 5
  291.  
  292.  
  293.  
  294.  
  295.                IF DataWaiting THEN
  296.                     C$ = CHR$(ReadChar)
  297.                END IF
  298.  
  299.           The DataWaiting function also monitors the state of the carrier
  300.           detect signal and triggers, in FULL mode, the user event trap
  301.           (UEVENT) if carrier is lost. As you can see a singular trap routine
  302.           catches carrier loss on output as well as input. You will notice
  303.           that the "KeyboardInput" subroutine (in SIMPLE.BAS) loops using
  304.           DataWaiting, and as such, carrier is constantly checked while
  305.           waiting for input. If the ReadChar function is called when no data
  306.           is available (as indicated by DataWaiting) a NULL character is
  307.           returned.
  308.  
  309.           In "Normal" mode, if XOFF/XON, CTS/RTS, or BOTH is enabled, then
  310.           the serial buffer will be protected from overfills. When the buffer
  311.           reaches 75% of capacity, an XOFF will be sent on the serial output
  312.           or RTS will be dropped. When the buffer empties out to 25% of
  313.           capacity, an XON will be sent or RTS raised. The capacity of the
  314.           input buffer is 2048 bytes. In FOSSIL mode, the threshold points
  315.           where flow control occurs and the buffer size, are determined by
  316.           the FOSSIL driver.
  317.  
  318.  
  319.                                  Carrier Detect Control
  320.  
  321.           There are three modes of carrier detection: Full, Partial, & None.
  322.           Each has it own distinct use for a particular purpose. The driver
  323.           defaults to FULL carrier detection unless you change it. The
  324.           following call is used to change control modes:
  325.  
  326.                CarrierDetect 0 [or] 1 [or] 2
  327.  
  328.           Specifying a TWO (2) sets carrier detection to FULL. This is the
  329.           default mode. When a loss of carrier occurs while transmitting,
  330.           polling for input data, or sitting in a wait loop (XOFF/XON or
  331.           CTS), the driver will return to the calling program and trip the
  332.           UEVENT flag. Tripping the UEVENT flag causes Basic to go to the
  333.           User Event trap routine (providing ON UEVENT GOSUB/UEVENT ON has
  334.           been set up in the user program). You should use this mode only if
  335.           you want to use the UEVENT trap for carrier loss detection. You
  336.           cannot transmit data (with the Transmit function) in this mode if
  337.           there is no carrier. You can send characters in this mode with the
  338.           WriteChar function.
  339.  
  340.           Specifying a ONE (1) sets carrier detection to PARTIAL. This mode
  341.           is similar to FULL with the exception that the UEVENT flag is not
  342.           tripped when carrier is lost. This mode should be used if UEVENT is
  343.           used for something else in your program, or you don't wish to
  344.           utilize UEVENT.
  345.  
  346.  
  347.  
  348.         QBSERIAL User Manual - V 3.10                              Page 6
  349.  
  350.  
  351.  
  352.  
  353.           Specifying a ZERO (0) sets carrier detection to NONE. An example of
  354.           this mode would be where "plain Jane" serial I/O is required (such
  355.           as communicating with a "dumb" terminal). In this application there
  356.           are no modem handshake signals (3 wire EIA/RS-232). This mode can
  357.           also be used for talking to a modem when there is no carrier signal
  358.           present (such as dialing and initialization commands). The Transmit
  359.           and WriteChar routines will always transmit data in this mode with
  360.           or without carrier present. Carrier detection must be disabled in
  361.           this mode to prevent calls to Uevent and disable the no carrier
  362.           escape mechanisms built into the XON/XOFF loops. Important: If you
  363.           are using "Normal" mode, and you are using the XOFF/XON protocol,
  364.           with "CarrierDetect 0" set, and receive an XOFF while transmitting,
  365.           you will sit forever waiting for an XON. This is a normal
  366.           condition, with the exception that there is no escape from this
  367.           loop other than XON. If you are using "FOSSIL" mode, this action is
  368.           undefined.
  369.  
  370.  
  371.                            Carrier Loss Detection by Polling
  372.  
  373.           As mentioned above, by default, the UEVENT trap is used to detect
  374.           when a loss of carrier occurs. There is also a function that allows
  375.           you to detect loss of carrier without using the UEVENT trap. While
  376.           I feel that using UEVENT is the simplest way to catch a carrier
  377.           loss in a program, it is possible that UEVENT might need to be used
  378.           by something else. This function is:
  379.  
  380.                X% = CarrierLost
  381.  
  382.           This function call allows to you to 'poll' for the state of
  383.           carrier. CarrierLost returns a NON-ZERO value when there is NO
  384.           carrier, and a ZERO when there IS carrier. CarrierLost is a real
  385.           time function, it returns the current carrier condition at the time
  386.           of the call. This allows you to code simple IF or DO loops to
  387.           detect loss:
  388.  
  389.                IF CarrierLost THEN
  390.                     ..process carrier loss
  391.                END IF
  392.  
  393.  
  394.                                       Modem Status
  395.  
  396.           NOTE:     This function ONLY works in Normal mode. It has no
  397.                     functional equivalent in FOSSIL mode.
  398.  
  399.           The Modem Status register contains bits that convey information
  400.           about the Modem's current state, and what has happened since the
  401.           last status query. In most instances these bits will not be needed
  402.  
  403.  
  404.  
  405.  
  406.         QBSERIAL User Manual - V 3.10                              Page 7
  407.  
  408.  
  409.  
  410.  
  411.           for normal serial operations. This was added to provide additional
  412.           information about the device in use.
  413.  
  414.           Normal Mode:
  415.  
  416.                Modem Status Register:
  417.  
  418.               7       6       5       4       3       2       1       0   Bit
  419.           ┌───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┐
  420.           │  128  │  64   │  32   │  16   │   8   │   4   │   2   │   1   │
  421.           │Carrier│ Ring  │DataSet│ Clear │ Delta │ Delta │ Delta │ Delta │
  422.           │Detect │Signal │ Ready │To Send│  CD   │  RI   │  DSR  │  CTS  │
  423.           └───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┘
  424.  
  425.           Bits 0 - 3 of this register report a change in the state of their  
  426.           respective RS-232 (signal) pins. A "1" in any of these bits means
  427.           that it's input has changed since last status read. Reading this
  428.           register clears bits 0 - 3. Bits 4 - 7 report the absolute state of
  429.           their respective RS-232 inputs (These bits are "real time").
  430.  
  431.           To use this function, the Basic statement would be:
  432.  
  433.                value% = ModemStatus
  434.  
  435.           The value returned by ModemStatus depends on the particular bit(s)
  436.           set in the Modem Status register. The corresponding decimal weights
  437.           are listed in the boxes in the above figure. As an example, if you
  438.           were monitoring the register and looking for a Ring Indication, you
  439.           would be looking for a value of 64. NOTE: If you are looking for a
  440.           particular value, you must AND the value you wish to test against
  441.           what ModemStatus returns. So, if you were looking for a Ring
  442.           Indication, you would use:
  443.  
  444.                St% = ModemStatus
  445.                if St% AND 64 then
  446.                     ... Ring detected
  447.  
  448.  
  449.                                                                            
  450.                                   Program Termination                      
  451.  
  452.           Since "OpenComm" seizes an interrupt vector, this vector needs to
  453.           be restored BEFORE your program ends. If you neglect to restore
  454.           this vector, you could be risking a crash. The routine used to
  455.           reset the vector is: CloseComm. Only use CloseComm if you specified
  456.           a port value in the OpenComm call (Normal or FOSSIL modes). If you
  457.           specified a port value of ZERO (Local mode) the interrupt vector is
  458.           NOT grabbed, and does not need to be reset. In Normal mode,
  459.           CloseComm resets any UART registers to their original value. In
  460.           FOSSIL mode, how the UART registers are left is undefined.
  461.  
  462.  
  463.  
  464.         QBSERIAL User Manual - V 3.10                              Page 8
  465.  
  466.  
  467.  
  468.  
  469.  
  470.                                Data Terminal Ready (DTR)
  471.  
  472.           Everybody that has used QuickBASIC's OPEN COMn statement is very
  473.           familiar with the problems of the DTR signal. Apparently Microsoft
  474.           felt that DTR would never be needed after a program terminates.
  475.           Anybody who has ever tried to write a door, or chain from one
  476.           program to another has cursed this decision at some time during
  477.           their programs development. This driver handles the DTR with a
  478.           different view. When you close the comm channel the DTR signal is
  479.           left in the same state it was when you opened the comm channel. For
  480.           door applications, this is a must. 
  481.  
  482.           A function call is provided however that allows your program to
  483.           control the DTR signal:
  484.  
  485.           DTRcontrol 1 [or] 0           ' 0 = DTR OFF, 1 = DTR ON
  486.  
  487.           Additionally when you use DTRcontrol to change the state of the DTR
  488.           signal it also instructs the driver to leave it this way when the
  489.           CloseComm function is called. Remember that the driver leaves DTR
  490.           the way it found it when OpenComm was called. If you used some
  491.           other method to change DTR after OpenComm was called, it would
  492.           automatically return to that original state when you called
  493.           CloseComm. Therefor only DTRcontrol should be used if you wish to
  494.           change the state of DTR. This appears to operate identically in
  495.           normal and FOSSIL modes.
  496.  
  497.  
  498.                                  Request To Send (RTS)
  499.  
  500.           NOTE:     This function ONLY works in Normal mode. It has no
  501.                     functional equivalent in FOSSIL mode.
  502.  
  503.           Request To Send (RTS) is a hardware flow control signal used to
  504.           tell the remote device to STOP sending data to us. Normally RTS is
  505.           set "on" and data will always flow (or the signal is ignored at the
  506.           remote end). With some communications programs RTS is used to
  507.           temporarily stop a modem from sending data while I/O is done to a
  508.           slow disk. This is especially true with high speed communications
  509.           where there is very little time between interrupts. This function
  510.           is independent of the automatic RTS flow control selected by
  511.           handshake 2 or 3 which tells the remote device to stop sending when
  512.           the input buffer is almost full. This function allows you to
  513.           manually control the state of RTS so you could, for instance, go
  514.           off and write the data somewhere without fear of loosing data.
  515.  
  516.           RTScontrol 1 [or] 0           ' 0 = RTS OFF, 1 = RTS ON
  517.  
  518.           When you use RTScontrol to change the state of the RTS signal it
  519.           also instructs the driver to leave it this way when the CloseComm
  520.           function is called. The driver leaves RTS the way it found it when
  521.  
  522.         QBSERIAL User Manual - V 3.10                              Page 9
  523.  
  524.  
  525.  
  526.  
  527.           OpenComm was called. If you used some other method to change RTS
  528.           after OpenComm was called, it will automatically return to that
  529.           original state when you call CloseComm. Therefor only RTScontrol
  530.           should be used if you wish to change the state of RTS. This is
  531.           similar in the way DTRcontrol works.
  532.  
  533.                               Driver Version and Copyright
  534.  
  535.           A function is available to access the drivers version and copyright
  536.           string. This would be used if you wish to display in your final
  537.           product the version of QBserial that your are using, and/or my
  538.           copyright along with yours. In order to access the copyright
  539.           string, the following lines should be added to your Basic program:
  540.  
  541.                     X& = DriverCopyright
  542.                     WHILE (PEEK(X&))
  543.                          CP$ = CP$ + CHR$(PEEK(X&))
  544.                          X& = X& + 1
  545.                     WEND
  546.  
  547.           This places the version/copyright string into string variable CP$.
  548.           This string may now be handled in whatever method you choose.
  549.  
  550.  
  551.                                  Crescent's PDQ Library
  552.  
  553.           An object module for use with PDQ is also included. PDQ does not
  554.           support UEVENT, so all references to UEVENT in the text should be
  555.           ignored. You will need to do carrier checking by polling with the
  556.           CarrierLost function. If you use FULL mode and carrier is lost it
  557.           will operate the same way as PARTIAL mode. The only exception to
  558.           this is the Transmit function, which when in FULL or PARTIAL mode,
  559.           will not transmit data.
  560.  
  561.  
  562.  
  563.                                         Linking
  564.  
  565.           Since object modules are provided for QB4.x, BC7, VBDOS, and PDQ,
  566.           you will need to select the proper one to use for your program. The
  567.           file QBSER.OBJ should be used for programs compiled with
  568.           QuickBASIC. BC7SER.OBJ is to be used for programs compiled with BC7
  569.           PDS, and Visual Basic for DOS. QBSERPDQ.OBJ is for PDQ users.
  570.           Typical link command lines would look like this: (Please note that
  571.           your command lines will probably be different if you use additional
  572.           libraries to generate your code). The term "yourprog" is meant to
  573.           imply any code modules necessary for linking your project. This
  574.           could one .OBJ file, or many. Please note that compiling any
  575.           linking projects from within the QB/QBX/VBDOS development
  576.           environment(s) is not supported.
  577.  
  578.  
  579.  
  580.         QBSERIAL User Manual - V 3.10                             Page 10
  581.  
  582.  
  583.  
  584.  
  585.           Link yourprog qbser;               (For QuickBASIC)
  586.  
  587.           Link yourprog bc7ser;              (For BC7 PDS and Visual Basic)
  588.  
  589.           Link yourprog qbserpdq acrtused;   (For PDQ)
  590.                                     ^
  591.                                     └──── See note about acrtused.obj
  592.  
  593.           NOTE:     In the past the file ACRTUSED.OBJ was required to be
  594.                     linked in when using the PDQ replacement libraries. This
  595.                     was necessary to satisfy a dummy external call. It
  596.                     appears that it may no longer be necessary to link with
  597.                     this file anymore. You should try linking without
  598.                     acrtused, and see if a link error occurs. If no error
  599.                     occurs, then you do not need to specify it.
  600.  
  601.  
  602.  
  603.                                     Quick Libraries
  604.  
  605.           If you wish to develop programs from within the environment, you
  606.           will first need to create a Quick library using one of the object
  607.           modules QBSER.OBJ, BC7SER.OBJ, or QBSERPDQ.OBJ. To create a Quick
  608.           lib for QuickBASIC 4.x, use the following Link command:
  609.  
  610.                Link QBSER,,,BQLB4x/q
  611.  
  612.           Where "BQLB4x" is one of the following: BQLB40.LIB, BQLB41.LIB, or
  613.           BQLB45.LIB. Use the one that came with your compiler. If you use
  614.           the wrong BQLB file you might get an "Invalid Format" error when
  615.           attempting to start QuickBASIC. QBSER.OBJ may also be added to
  616.           Quick Libraries containing other routines and OBJ's as well.
  617.  
  618.           To create a Quick Library for use within QBX (BC7's environment)
  619.           use the following link command (IMPORTANT: be sure to use Link
  620.           v5.xx that came with BC7 or you will receive linking errors):
  621.  
  622.                Link BC7SER,,,QBXQLB/q;
  623.  
  624.           To create a Quick Library for use within Visual Basic's environment
  625.           (VBDOS) use the following link command (IMPORTANT: be sure to use
  626.           Linker that came with VBDOS or you will receive linking errors):
  627.  
  628.                Link BC7SER,,,VBDOSQLB/q;
  629.  
  630.           For PDQ, use the method for QB4.x, since you will be using the
  631.           built in run time routines built into the environment. You ONLY use
  632.           QBSERPDQ.OBJ when you link the EXEcutable file.
  633.  
  634.           Remember too, that you can also add BC7SER.OBJ to Quicklibs
  635.           containing other routines.
  636.  
  637.  
  638.         QBSERIAL User Manual - V 3.10                             Page 11
  639.  
  640.  
  641.  
  642.  
  643.                                      Specifications
  644.  
  645.           The following port addresses and default interrupts are used in
  646.           Normal mode:
  647.  
  648.                Comm      Base Address        IRQ (Default)
  649.  
  650.                 1          3F8 hex            4
  651.                 2          2F8 hex            3
  652.                 3          3E8 hex            4
  653.                 4          2E8 hex            3
  654.  
  655.           Please read the section explaining the OpenComm function for
  656.           information on how to use addresses or IRQ's other than the
  657.           defaults.
  658.  
  659.  
  660.                                 Registration and Support
  661.  
  662.           QBserial is distributed as shareware. You may copy and distribute
  663.           it freely, as long as you do NOT modify it or add (or remove) any
  664.           files to it.
  665.  
  666.           QBserial is not free software, and requires registration. There are
  667.           two classes of registration which are dependant upon use:
  668.           Commercial and Non-Commercial.
  669.  
  670.           Registration of QBserial is $25 for non-commercial use. Non-
  671.           commercial uses are: Personal use, or use in another shareware
  672.           product such as doors and utilities where you allows others to try
  673.           the product first before buying and request a nominal registration
  674.           fee. Source code is available as an option for an additional $50.
  675.  
  676.           Registration of QBserial for commercial use is $75. Commercial uses
  677.           are: Inclusion of QBserial into ANY product that is to be sold for
  678.           profit, or any use of this program in a business environment. Any
  679.           program that must be paid for in advance before the product is
  680.           delivered, or use in a corporate environment fits this category.
  681.           Commercial registration includes the source code for QBserial in C
  682.           (Microsoft C), if desired.
  683.  
  684.           Please register your copy!
  685.  
  686.           Software and Shareware distribution houses may charge a nominal
  687.           distribution and copying fee not to exceed $5.00. They may not sell
  688.           this program outright or ask you for the registration fee directly,
  689.           they must tell you that registration is required by the author.
  690.  
  691.           If you have access to a BBS that is an ILINK network member, you
  692.           can reach me in the respective Basic conferences. If you do not
  693.           have ILINK access anywhere nearby, then you can always contact me
  694.           on the SailBoard BBS at the number listed below. I would prefer if
  695.  
  696.         QBSERIAL User Manual - V 3.10                             Page 12
  697.  
  698.  
  699.  
  700.  
  701.           you contact me directly on the SailBoard however, as mail networks
  702.           aren't always as reliable as I'd like, and I have missed messages.
  703.           I'll do the best I can to help if you have questions. Bugs will be
  704.           tended to if required, and good suggestions tend to be implemented.
  705.  
  706.  
  707.                                       Source Code
  708.  
  709.           The source code for QBserial is available. The source is available
  710.           by signing at the appropriate place on the registration form. The
  711.           source may be used for you own internal uses only. The source may
  712.           not be distributed by you to any other person, even if you make
  713.           changes to it. Nor can the resulting object code be sold or
  714.           distributed. Modifications can only be used in your end product,
  715.           and without any type of royalty. The source is available only after
  716.           you register QBserial. The license fee for the QBserial source code
  717.           is $50.00 for Non-Commercial users. Commercial users receive the
  718.           source as part of their registration fee if they desire it.
  719.  
  720.                                       Jeff Sumberg
  721.                                Sysop of the SailBoard BBS
  722.                                Ringwood, NJ, 201-831-8152
  723.  
  724.                                         [ or ]
  725.  
  726.                                         Box 212
  727.                                   Ringwood, NJ, 07456
  728.  
  729.  
  730.  
  731.                                     Acknowledgments
  732.  
  733.           Thanks go out to Mark "Sparky" Herring for using these routines in
  734.           his highly successful Qmail door.
  735.  
  736.           Thanks to Brent Yandell for using these routines in his PCBoard
  737.           File Viewer PCBFV and PCBFX programs.
  738.  
  739.           Thanks to Mark Wilson for some very good ideas in version 2.0.
  740.           Thanks to Michael Conley for finding a real time sensitive
  741.           interrupt problem and for providing very useful information.
  742.           Thanks to Jeffrey Morley (author of ZipLab) for testing.
  743.  
  744.  
  745.                                Distribution File Contents
  746.  
  747.            QBSER.OBJ     QBserial object module for use with QuickBASIC
  748.                          version 4.x.
  749.  
  750.            QBSERPDQ.OBJ  QBserial object module for use with PDQ and
  751.                          QuickBASIC 4.x or PDQ with Basic Compiler 7.x (NEAR
  752.                          string model).
  753.  
  754.         QBSERIAL User Manual - V 3.10                             Page 13
  755.  
  756.  
  757.  
  758.  
  759.  
  760.            BC7SER.OBJ    QBserial object module for use with Basic Compiler
  761.                          6.x, Basic Compiler 7.x (NEAR or FAR string models),
  762.                          and Visual Basic for DOS.
  763.  
  764.            ACRTUSED.OBJ  Dummy object module to satisfy an external reference
  765.                          when linking with PDQ files. May no longer be
  766.                          necessary. See Text.
  767.  
  768.            OFFHOOK.BAS   Sample Basic program. Used to take modem off hook.
  769.                          References PCBoard data files for port info. Can
  770.                          also be used stand alone.
  771.  
  772.            PCBDOOR.BAS   Very simple frame for creating a door in PCBoard.
  773.                          Should be used ONLY as a guide.
  774.  
  775.            SIMPLE.BAS    Very simple "do nothing" program offering examples
  776.                          of how to call QBserial functions.
  777.  
  778.            QBSERIAL.DEC  Function declarations for QBserial.
  779.  
  780.            QBSERIAL.DOC  QBserial Documentation (this file).
  781.  
  782.            READ.ME       Latest changes to QBserial.
  783.  
  784.            REGISTER.FRM  QBserial Registration form. Please Register your
  785.                          copy.
  786.  
  787.            FILE_ID.DIZ
  788.            DESC.SDI      BBS description files.
  789.  
  790.  
  791.                                  Changes and Revisions
  792.  
  793.           06/09/89  1.0  Initial Release
  794.  
  795.           06/21/89  1.1  Added carrier detection control. Calling program can
  796.                          turn detection off and on as desired. Necessary if
  797.                          data sending/receiving required if carrier isn't
  798.                          present.
  799.  
  800.           09/01/89  1.2  Fixed a bug in Readchar where 'extended' characters
  801.                          (ASCII 128 to 255) were causing an Illegal Function
  802.                          Call in the CHR$() conversion (because they were
  803.                          being returned as negative numbers). Extended
  804.                          character may now be received properly. Added three
  805.                          new functions: CDtrap, CarrierLost, and DTRcontrol.
  806.  
  807.  
  808.           03/24/90  1.5  Added support for Basic Compiler 7.0 PDS and PDQ.
  809.                          Added sections to manual about Linking, Source code
  810.                          availability, and updated section on Quicklibs.
  811.  
  812.         QBSERIAL User Manual - V 3.10                             Page 14
  813.  
  814.  
  815.  
  816.  
  817.                          Separate object files now supplied for QB, BC7, and
  818.                          PDQ.
  819.  
  820.           05/01/90  1.6  Oops! PDQ users found out fast that I forgot to
  821.                          compile the PDQ module with stack checking removed.
  822.                          I also forgot to include ACRTUSED.OBJ to satisfy
  823.                          linking requirements. Sorry 'bout that! Released
  824.                          only as beta to those that needed it.
  825.  
  826.           11/01/90  2.0  Added capability to specify non-standard port
  827.                          addresses and which IRQ to use when the port is
  828.                          opened. Removed CDtrap function. Created new carrier
  829.                          detection modes using the CarrierDetect function. (0
  830.                          = NONE, 1 = PARTIAL, 2 = FULL). Also added
  831.                          DriverCopyright function to allow program access to
  832.                          the driver version.
  833.  
  834.           02/08/92  2.10 Added RTS flow control support. RTS will be used to
  835.                          control data coming in to QBserial when the
  836.                          handshake is set to 2 (CTS/RTS). Removed necessity
  837.                          for SERIAL.LIB library file by adding inline
  838.                          assembler that performed the routines that were
  839.                          previously included in that library. QBserial is now
  840.                          compiled with Microsoft C 6.0 which will give
  841.                          smaller, faster, and more efficient code than QuickC
  842.                          could generate. This is especially true in the
  843.                          interrupt area. Added new function RTScontrol, to
  844.                          allow program to control RTS line directly.
  845.                          Increased size of input buffer from 1024 to 2048
  846.                          bytes. Changed method in which interrupt controller
  847.                          mask bits were set & cleared. Corrected error found
  848.                          in documentation describing the function of
  849.                          CarrierDetect.
  850.  
  851.           06/20/92  2.20 Added support for extended IRQs. QBserial now
  852.                          supports IRQ 8 - 15. Added a new sample program to
  853.                          the QBserial distribution package (OFFHOOK.BAS) to
  854.                          demonstrate usage of QBserial.
  855.  
  856.           07/05/92  2.25 While experimenting with some programs of my own I
  857.                          found a some errors in the disabling of the IRQ
  858.                          masks on the Interrupt Controller when exiting from
  859.                          QBserial. The program has been changed so that if
  860.                          the IRQ you specify is already turned ON when
  861.                          OpenComm executes, QBserial will leave it ON when
  862.                          you do a CloseComm. In versions since 2.10, the IRQ
  863.                          mask was always turned OFF when CloseComm was
  864.                          executed. This caused other communications programs
  865.                          such as BBS's that don't reset the port when
  866.                          returning from QBserial to appear to "lock up" when
  867.                          they regained control.
  868.  
  869.  
  870.         QBSERIAL User Manual - V 3.10                             Page 15
  871.  
  872.  
  873.  
  874.  
  875.           11/01/92  3.00 Added the ability for QBserial to use FOSSIL
  876.                          drivers. Modified the OpenComm call to allow the
  877.                          programmer to specify which mode to operate in. The
  878.                          QBSERIAL.DEC file has changed and the one provided
  879.                          with this version MUST be used when upgrading to
  880.                          this version. Added new function: ModemStatus, to
  881.                          read the Modem Status register of the UART. This is
  882.                          a normal mode function only.
  883.  
  884.           06/12/93  3.10 This version is a bug fix version. Several minor
  885.                          errors and omissions have been reported by users,
  886.                          and these have been corrected in this version. These
  887.                          include:
  888.                          - Modified the QBSERIAL.DEC file to allow Qbserial
  889.                          to work with Visual Basic for DOS. This is because
  890.                          of an unknown, undocumented change in the way
  891.                          DECLARE works in Visual Basic for DOS.
  892.                          - ClearInputBuffer did not work in FOSSIL mode.
  893.                          - Modified OpenComm to reset flow control flags,
  894.                          buffer pointers, etc. It was found that if a port
  895.                          was opened, used, closed, then opened again without
  896.                          program termination or chain from program to
  897.                          program, that the Flow Control mode would be wrong
  898.                          or inoperative. The input buffer also was not
  899.                          flushed when a port was opened. This was because
  900.                          initialization to these flags and pointers was only
  901.                          being done when the EXE was loaded, not during
  902.                          OpenComm. These are done within OpenComm.
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.         QBSERIAL User Manual - V 3.10                             Page 16
  929.